<?php
require_once("../config.php"); 
require_once("../model/DB.php");
require_once("../model/Kid.php");
require_once("../model/Class.php");

if($_POST['id']!=0){
	if($_POST['class']=="auto"){
		$class = Classes::autoClass($_POST['grade']);
		if(Kid::editKid($_POST['id'],$_POST['name'],$_POST['gender'],$_POST['nation'],$_POST['parent'],$class['class_id'],$_POST['age'],$_POST['height'],$_POST['weight'])){
			echo "saved";
		}
	}
	else{
		if(Kid::editKid($_POST['id'],$_POST['name'],$_POST['gender'],$_POST['nation'],$_POST['parent'],$_POST['Class'],$_POST['age'],$_POST['height'],$_POST['weight'])){
			echo "saved";
		}	
	}
}
else{
	if($_POST['class']=="auto"){
		$class = Classes::autoClass($_POST['grade']);
		if(Kid::addKid($_POST['name'],$_POST['gender'],$_POST['nation'],$_POST['parent'],$class['class_id'],$_POST['age'],$_POST['height'],$_POST['weight'])){
			echo "added";
		}
	}
	else{
		if(Kid::addKid($_POST['name'],$_POST['gender'],$_POST['nation'],$_POST['parent'],$_POST['Class'],$_POST['age'],$_POST['height'],$_POST['weight'])){
			echo "added";
		}
	}
}


?>